#include "oled_show.h"

/*include show*/
#include "arry_icons8_hema_bmp.h"
#include "arry_icons8_sun_bmp.h"
#include "arry_icons8_idea_bmp.h"
#include "arry_icons8_cake1_bmp.h"
#include "arry_icons8_cake2_bmp.h"

#define image_width 120   // 图像的宽度
#define image_height 120  // 图像的高度

int show_content(u8g2_t *u8g2,int show_state,char grade)
{
    /*居中显示公式*/
    int screen_width = 128; // 屏幕的宽度
    int screen_height = 160; // 屏幕的高度
    int x = (screen_width - image_width) / 2;  
    int y = (screen_height - image_height) / 2;
    switch (grade)
    {
    case 1:
        for (size_t i = 0; i < FRAME_icons8_sun_bmp; i++)
        {
            u8g2_ClearBuffer(u8g2); 
            u8g2_DrawXBM(u8g2, x, y, 120, 120, frames_icons8_sun_bmp[i]);
            u8g2_SendBuffer(u8g2);
            if (show_state == 1)
            {
                show_state = 0;
                break;
            }
            vTaskDelay(10 / portTICK_PERIOD_MS);
            // frame = (frame + 1) % FRAME_COUNT; 
        }
        break;
    case 2:
        for (size_t i = 0; i < FRAME_icons8_hema_bmp; i++)
        {
            u8g2_ClearBuffer(u8g2); 
            u8g2_DrawXBM(u8g2, x, y, 120, 120, frames_icons8_hema_bmp[i]);
            u8g2_SendBuffer(u8g2);
            if (show_state == 1)
            {
                show_state = 0;
                break;
            }
            vTaskDelay(10 / portTICK_PERIOD_MS);
            // frame = (frame + 1) % FRAME_COUNT; 
        }
        break;

    case 3:
        for (size_t i = 0; i < FRAME_icons8_idea_bmp; i++)
        {
            u8g2_ClearBuffer(u8g2); 
            u8g2_DrawXBM(u8g2, x, y, 120, 120, frames_icons8_idea_bmp[i]);
            u8g2_SendBuffer(u8g2);
            if (show_state == 1)
            {
                show_state = 0;
                break;
            }
            vTaskDelay(10 / portTICK_PERIOD_MS);
            // frame = (frame + 1) % FRAME_COUNT; 
        }
        break;
    case 4:
    for (size_t i = 0; i < FRAME_icons8_cake1_bmp; i++)
{
      u8g2_ClearBuffer(u8g2); 
     u8g2_DrawXBM(u8g2, x, y, 120, 120, frames_icons8_cake1_bmp[i]);
      u8g2_SendBuffer(u8g2);
      if (show_state == 1)
      {
          show_state = 0;
          break;
      }
      vTaskDelay(10 / portTICK_PERIOD_MS);
      // frame = (frame + 1) % FRAME_COUNT; 
}
    break;
    case 5:
    for (size_t i = 0; i < FRAME_icons8_cake2_bmp; i++)
{
      u8g2_ClearBuffer(u8g2); 
     u8g2_DrawXBM(u8g2, x, y, 120, 120, frames_icons8_cake2_bmp[i]);
      u8g2_SendBuffer(u8g2);
      if (show_state == 1)
      {
          show_state = 0;
          break;
      }
      vTaskDelay(10 / portTICK_PERIOD_MS);
      // frame = (frame + 1) % FRAME_COUNT; 
}
    default:
        break;
    }
    return show_state;
}
